import React from 'react';
import { connect } from 'react-redux';
import { addTodo } from '../actions';
import Modal from '../components/Modal';
import '../components/modal.css';

let AddTodo = ({ dispatch }) => {
  let input

	return  (
		<div>
			<form onSubmit={e => {
			  e.preventDefault();
				if (!input.value.trim()) {
			    return
				}
				dispatch(addTodo(input.value));
				input.value = ''
			}}>
				<input ref={node => {
				  input = node
				}} />
				<button type="submit">
					Add Todo
				</button>
			</form>
			<Modal cancelCallback={dispatch(addTodo("a7"))} confirmCallback={dispatch(addTodo('8'))} title="温馨提示" id="activiteModal" confirmText="确认" cancelText="取消" size='modal-sm'>您确定对本记录使用加息券加息？</Modal>
		</div>
	)
}

AddTodo = connect()(AddTodo)

export  default AddTodo